<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>示例07</title>
    <style>
        *{
            margin: auto;
            text-align: center;
        }
        .div1{
            width: 100px;
            height: 100px;
            background: red;
            margin-top: 20px;
        }
        button{
            padding: 10px;
            border: none;
            background-color: green;
            color: #fff;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div id="app">
        <button v-on:click='fn'>toggle</button>
        <div class="div1" v-show='bo1'></div>
    </div>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script>
    var vm = new Vue({
        el: '#app',
        data: {
            bo1: false,
        },
        methods: {
            fn: function () {
                this.bo1 = !this.bo1;
            }
        }
    })
</script>
</body>
</html>